<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let p = new Promise(function (resolve, reject) {
            // 异步器 定时器 ajax
            setTimeout(() => {
                if (Math.random() >= .5) {
                    resolve('success');
                } else {
                    reject('fail');
                }
            }, 100);
        });
        p.then((data) => {
            console.log(data);
        }, (reason) => {
            console.log(reason);
        });
    </script>
</body>

</html>